package com.fanshe;

import org.junit.Test;

/**
 * 通过反射创建对应的运行时类的对象
 */
public class NewInstanceTest {

    @Test
    public void test1() throws IllegalAccessException, InstantiationException {
        Class clazz = Person.class;

        /**
         * newInstance():调用此方法，创建对应的运行时类的对象。内部调用了运行时类的空参构造器
         */
        Object object = clazz.newInstance();

        System.out.println(object);
    }
}
